

----socket采用luasocket
local mysql = require("socket.mysql")

local _M = {
    _VERSION = '0.1'
}
function _M._mysql_new(self,tb)
    local mysql_db = mysql:new()      --mysql
    mysql_db:set_timeout(tb.mysql_timeout) 
    local ok_mysql, mysql_err, errno, sqlstate = mysql_db:connect({
        host = tb.mysql_host,
        port = tb.mysql_port,
        database = tb.mysql_db,
        user = tb.mysql_user,
        password = tb.msyql_pass})
    if not ok_mysql then
        return nil,mysql_err
    end
    return mysql_db
end

return _M

